package org.brain.bean;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import org.brain.dbo.DBOperate;
import org.brain.pojos.Treemenu;
import org.brain.pojos.User;
import org.brain.tool.ToolBean;

import antlr.build.Tool;

@ManagedBean(name="childNode")
@SessionScoped

public class ChildNodeMenu {

	List<Treemenu> childTree = new ArrayList<Treemenu>();//docuemnt List
	String id; //docuemnt id
	String idReserve; //
	int row;
	User user;
	
	/*
	 * get id from URI
	 * */
	
	/*
	 * init document list from database
	 * 
	 * */
	
	public void initList()
	{	
		
		user = ToolBean.getUserSession();
		id = ToolBean.getRequestParameter("id"); 
		//当点击导航按钮时，会发送一个请求。默认是不带id参数的。这个我们为它，记录一个参数 
		if(id!=null)
			idReserve = id;
		else
			id = idReserve;
		childTree.clear();
		childTree = DBOperate.getTreeMenu(user.getUsername(), Integer.parseInt(id));
		//childTree = DBOperate.search("Document where nodeid="+id);
		row=childTree.size();
		System.out.println("documentid "+id);
		
	}

	public List<Treemenu> getChildTree() {
		initList();
		return childTree;
	}
	
	public void setChildTree(List<Treemenu> childTree) {
		this.childTree = childTree;
	}

	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}

	public int getRow() {
		return row;
	}

	public void setRow(int row) {
		this.row = row;
	}
	
}
